<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <span>年</span>
    <input type="text" id="nian" />
    <span>月</span>
    <input type="text" id="yue" />
    <span>日</span>
    <input type="text" id="ri" />
    <button id="but">点击</button>
    <span>天</span>
    <input type="text" id="tian" />
    <script>
        var n = document.getElementById("nian");
        var y = document.getElementById("yue");
        var r = document.getElementById("ri");
        var but = document.getElementById("but");
        var t = document.getElementById("tian");
        but.onclick = function() {
            //获取年
            var nian = n.value;
            //判断年的取值范围
            if (nian >= 1000 && nian <= 2000 && nian % 1 === 0) {
                // console.log(nian);
                //获取月
                var yue = y.value;
                //获取月的取值范围
                if (yue >= 1 && yue <= 12 && yue % 1 === 0) {
                    // console.log(yue);
                    //获取日
                    var ri = r.value;
                } else {
                    alert("请输入1-12的数字");
                }
            } else {
                alert("请输入1000-2000之间的数字");
            }
        };
    </script>
</body>

</html>